require.config({
	paths: {
		'backbone': './libs/backbone',
		'jquery': './libs/jquery',
		'underscore': './libs/underscore',
		'text': './libs/text',
		'css': './libs/css',
		'cookie': './libs/cookie',
		// 每个页面的js
		'homejs': 'home/js/homejs',
		'marketjs': 'market/js/marketjs',
		'loginjs': 'login/js/loginjs',
		'minejs': 'mine/js/minejs',
		'shoppingjs': 'shoppingCart/js/shoppingjs'
	}
});

require(['router', 'jquery', 'cookie'/*, 'wx'*/], function (router, $, cookie/*, wx*/) {

	// 页面加载完毕时判断当前在哪个页面，并更改相应页面的图标
	$(document).ready(function() {
		// 1.文档底部图标
		var $as = $('#footer>a');
		// 判断当前路径
		var route = window.location.hash;
		if (route == '#home' || route == '') {
			$as.eq(0).find('div').css('backgroundImage', 'url(./resource/y0.png');
		} else if (route == '#market') {
			$as.eq(1).find('div').css('backgroundImage', 'url(./resource/y1.png');
		} else if (route == '#shoppingCart') {
			$as.eq(2).find('div').css('backgroundImage', 'url(./resource/y2.png');
		} else if (route == '#mine') {
			$as.eq(3).find('div').css('backgroundImage', 'url(./resource/y3.png');
		}

		for (let i = 0; i < $as.length; i++) {
			// 添加点击事件
			$as[i].addEventListener('touchend', function () {
				for (let j = 0; j < $as.length; j++) {
					$as.eq(j).find('div').css('backgroundImage', 'url(./resource/' + j + '.png)');
					$as.eq(j).find('div').removeClass('animated tada');
				}
				$as.eq(i).find('div').css('backgroundImage', 'url(./resource/y' + i + '.png)');
				$as.eq(i).find('div').addClass('animated tada');
			});
		}

		// 购物车角标
		var username = cookie.getCookie('username');
		var password = cookie.getCookie('password');
		if (username == '18310148117' && password == '123456') {
			$('#count').css('display', 'inline-block');
		} else {
			$('#count').css('display', 'none');
		}
	});
});

